創造者模式在 Kotlin 都已經內建好,但是和單例模式不同的地方是 Kotlin 的創造者模式是能直接用的,就是舒服
data class Member(
var name: String = "",
var age: String = "",
var address: String = "",
var point: String = "",
)
val member = Member().apply {
name = "AndyAWD"
age = "18"
address = "Kaohsiung"
point = "9527"
}
你看,很簡單吧.jpg